<%@ page pageEncoding="utf-8" contentType="text/html" %>
<%@ page import="model.Paper" %>
<%@ include file="header.tpl.jsp"%>

<%
Paper[] paper_list = (Paper[]) request.getAttribute("paper_list[]");
String[] paper_author = (String[]) request.getAttribute("paper_author[]");
%>

<div id="left">
	<h2>Welcome to +Quiz!</h2>
	<img alt="" src="image/pencil.png" />
</div>

<div id="right">
	<div class="box">
	<%if(!user.isLoggedIn()){%>
		<h2>用户登录</h2>
		<form action="Login" method="post">
			<table>
				<tr><th><label for="email">E-mail:</label></th><td><input type="text" id="email" name="email" /></td></tr>
				<tr><th><label for="password">密码:</label></th><td><input type="password" id="password" name="password" /></td>
			</table>
			<div class="post_buttons">
				<button type="submit">登录</button><button type="button" onclick="location.href='Register';">注册</button>
			</div>
		</form>
	<%}else{%>
		<h2>用户信息</h2>
		<dl><dt>用户名:</dt><dd><%=user.getUsername()%></dd></dl>
		<dl><dt>用户组:</dt><dd><%=user.getGroupName()%></dd></dl>
		<div>欢迎回来, <%=user.getUsername()%>! 你是本站的第<%=user.getUid()%>个成员！ </div>
	<%}%>
	</div>

	<div class="box">
		<h2>最新试题</h2>
		<ul>
		<%for(int i = 0; i < paper_list.length; i++){%>
		<%Paper p = paper_list[i];%>
			<li><a href="QuestionList?pid=<%=p.getPid()%>"><%=p.getTitle()%></a> <i>作者： <%=paper_author[i]%></i></li>
		<%}%>
		</ul>
	</div>
</div>

<div id="clear"></div>

<%@ include file="footer.tpl.jsp"%>